home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / oper_sys / emerald / emrldsys.lha / Kernel / Em / request.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-17  |  2.3 KB  |  84 lines

  1.  
  2. /*  C O P Y R I G H T   N O T I C E :                                     */
  3. /* Copyright 1986 Eric Jul and Norm Hutchinson.     May not be used for any  */
  4. /* purpose without written permission from the authors.              */
  5.  
  6. /* This source module contains the stuff to dynamically load an object    */
  7. /* from a Ultrix file or from another kernel.                             */
  8.  
  9. #include "Kernel/h/system.h"
  10. #include "Kernel/h/macros.h"
  11. #include "Kernel/h/assert.h"
  12. #include "Kernel/h/mmMsgTypes.h"
  13. #include "Kernel/h/emTypes.h"
  14. #include "Kernel/h/map.h"
  15. #include "Kernel/h/emkDefs.h"
  16.  
  17. GenericReqPtr               reqStack;
  18.  
  19. /************************************************************************/
  20. GenericReqPtr MakeNewRequest(fTag, fSizeInBytes)
  21. ReqTag                      fTag;
  22. int                         fSizeInBytes;
  23. {
  24.     register GenericReqPtr  x;
  25.  
  26.     if (NonNULL(reqStack)) {
  27.     x                   = reqStack;
  28.     reqStack            = reqStack->hdr.next;
  29.     x->hdr.rTag         = fTag;
  30.     x->hdr.next         = (GenericReqPtr) NULL;
  31.         /* assert the maps hdr.reqBy and hdr.wantList are cleared */
  32.     } else {
  33.     x                   = (GenericReqPtr) malloc(sizeof(GeneralReq));
  34.     x->hdr.rTag         = fTag;
  35.     x->hdr.next         = (GenericReqPtr) NULL;
  36.     x->hdr.reqBy        = Map_Create();
  37.     x->hdr.wantList     = Map_Create();
  38.     }
  39.  
  40.     return x;
  41. }
  42.  
  43.  
  44. void FreeRequest(fReq)
  45. register GenericReqPtr       fReq;
  46. {
  47.     assert(Map_Count(fReq->hdr.wantList) == 0);
  48.     if (Map_Count(fReq->hdr.reqBy) > 0) {
  49.     Map_Clear(fReq->hdr.reqBy);
  50.     }
  51.     fReq->hdr.next          = reqStack;
  52.     reqStack                = fReq;
  53.     
  54. #ifdef DELETEOFREQ    
  55.     Map_Destroy(fReq->hdr.reqBy);
  56.     Map_Destroy(fReq->hdr.wantList);
  57.     free(fReq);
  58. #endif DELETEOFREQ
  59. }
  60.  
  61. /**********************************************************************/
  62. /*      DoCallBack                                                    */
  63. /**********************************************************************/
  64.  
  65. void DoCallBack(fReq, fOID)
  66. GenericReqPtr   fReq;
  67. OID             fOID;
  68. /* Perform the call back with the given OID */
  69. {
  70.     GenericReqPtr           oldReq;
  71.     int                     dummy;
  72.     
  73.     Map_For(fReq->hdr.reqBy, oldReq, dummy)
  74.     Map_Delete(oldReq->hdr.wantList, (int) fReq);
  75.     (*oldReq->hdr.callBack)(oldReq, fOID);
  76.     Map_Next
  77. }
  78.  
  79. void RequestInit()
  80. {
  81.     reqStack                = (GenericReqPtr) NULL;
  82. }
  83.  
  84.